package per.hx.bs.util;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.SessionDAO;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import per.hx.bs.shiro.ShiroUser;

import java.security.Principal;
import java.util.Collection;
import java.util.List;

/**
 * @author HuXing
 * @date 2018/3/21  16:34
 */
public class ShiroUtils {


    private static Subject getSubjct() {
        return SecurityUtils.getSubject();
    }

    public static ShiroUser getUser() {
        Object object = getSubjct().getPrincipal();
        return (ShiroUser) object;
    }

    public static Long getUserId() {
        return getUser().getUserId();
    }

    public static void logout() {
        getSubjct().logout();
    }

}
